package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo3Filter {
  def main(args: Array[String]): Unit = {

    /**
      * map  传入一行返回一行
      *
      */
    //创建sparkp配置文件对象
    val conf = new SparkConf().setAppName("map").setMaster("local")

    //上下文对象
    val sc = new SparkContext(conf)

    //将scala集合转换成RDD
    val rdd1: RDD[Int] = sc.parallelize(List(1, 2, 3, 4, 5, 6, 7, 8, 9))


    //取出所有偶数
    //filter  懒执行
    val filterRDD = rdd1.filter(i => i % 2 == 0)


    filterRDD.foreach(println)



  }
}
